package cn.wolfcode.luowowo.service.impl;

import cn.wolfcode.luowowo.article.domain.Wenda;
import cn.wolfcode.luowowo.article.domain.WendaTag;
import cn.wolfcode.luowowo.article.mapper.WendaTagMapper;
import cn.wolfcode.luowowo.article.service.IWendaTagService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
@Service
public class WendaTagServiceImpl implements IWendaTagService {
    @Autowired
    private WendaTagMapper wendaTagMapper;

    @Override
    public void saveOrUpdate(WendaTag wendaTag) {
        if(wendaTag.getId() == null){
            wendaTagMapper.insert(wendaTag);
        }else {
            wendaTagMapper.updateByPrimaryKey(wendaTag);
        }
    }

    @Override
    public void delete(Long id) {
        wendaTagMapper.deleteByPrimaryKey(id);
    }

    @Override
    public WendaTag get(Long id) {
        return wendaTagMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<WendaTag> selectByWendaId(Long wendaId) {
        return wendaTagMapper.selectByWendaId(wendaId);
    }

    @Override
    public List<WendaTag> selectAll() {
        List<WendaTag> tags = wendaTagMapper.selectAll();
        return tags;
    }
}
